#include <iostream>

using namespace std;

const int N = 1e4 + 10;

int n;
int a[N], b[N], g[N], k[N];
int x, y; 

int find()
{
	// 从后往前枚举
	for(int i = n; i >= 1; i--)
	{
		// 判断是否覆盖
		if(x >= a[i] && y >= b[i] && x <= a[i] + g[i] && y <= b[i] + k[i])
		{
			return i;
		}
	}

	return -1;
}

int main()
{
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i] >> b[i] >> g[i] >> k[i];
	cin >> x >> y;

	// 地毯从后往前查找
	cout << find() << endl;

	return 0;
}


